#ifndef DIALOG_H
#define DIALOG_H

#include <QDialog>
#include <QMouseEvent>
#include <QPainter>
#include <QPushButton>

namespace Ui {
class Dialog;
}

class Dialog : public QDialog {
    Q_OBJECT

public:
    explicit Dialog(QWidget* parent = 0);
    ~Dialog();

protected:
    virtual void paintEvent(QPaintEvent*) override;
    virtual void mousePressEvent(QMouseEvent*) override;
    virtual void mouseMoveEvent(QMouseEvent*) override;
    virtual void mouseReleaseEvent(QMouseEvent*) override;

private slots:
    void zoomIn();

private:
    Ui::Dialog* ui;

    QPixmap pixmap;            // 画布
    QPixmap tmpPixmap;         // 辅助画布
    bool    isDrawing = false; // 标志是否正在绘图
    QPoint  lastPoint;
    QPoint  endPoint;
    qreal   scale = 1; // 设置初始放大倍数为1,即不放大

    QPushButton* button = new QPushButton(this); // 新建按钮对象
};

#endif // DIALOG_H
